package com.mashen.client.model;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.mashen.util.Constant;

public class ButtonRequest {
	private List<Button> button=new ArrayList<Button>();
	public void addButton(Button btn){
		button.add(btn);
	}
	public List<Button> getButton() {
		return button;
	}
	public void setButton(List<Button> button) {
		this.button = button;
	}
	/**
	 * 返回默认的button
	 * @return
	 */
	public static String getDefaultButton(){
		Button btn1=new Button();
		btn1.setName("同行活动");
		Button subbtnhaibao=new Button();
		subbtnhaibao.setName("生成海报");
		subbtnhaibao.setType("click");
		subbtnhaibao.setKey(Constant.CREATE_PIC);
		btn1.addSubButton(subbtnhaibao);
		
		Button btn2=new Button();
		btn2.setName("搜融在线");
		btn2.setType("view");
		btn2.setUrl("http://www.baidu.com");
		
		Button btn3=new Button();
		btn3.setName("搜融周刊");
		btn3.setType("view");
		btn3.setUrl("http://www.baidu.com");
		
		ButtonRequest req=new ButtonRequest();
		req.addButton(btn1);
		req.addButton(btn2);
		req.addButton(btn3);
		
		String buttonjsonstr=JSONObject.toJSONString(req);
		System.out.println(buttonjsonstr);
		return buttonjsonstr;
	}
	public static void main(String[] args) {
		System.out.println(ButtonRequest.getDefaultButton());
	}
}
class Button{
	private String name;
	private String type;
	private String key;
	private String url;
	private List<Button> sub_button=new ArrayList<Button>();
	
	public void addSubButton(Button btn){
		sub_button.add(btn);
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public List<Button> getSub_button() {
		return sub_button;
	}
	public void setSub_button(List<Button> sub_button) {
		this.sub_button = sub_button;
	}
	
}
